# Contributor: omni <omni@gitlab.alpinelinux.org>
# Maintainer: omni <omni@gitlab.alpinelinux.org>
pkgname=amfora
pkgver=1.10.0 # Don't forget to update main.commit below
pkgrel=1
pkgdesc="terminal browser for the Gemini protocol"
url="https://github.com/makeworld-the-better-one/amfora"
license="GPL-3.0-or-later"
arch="all"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/makeworld-the-better-one/amfora/archive/v$pkgver.tar.gz
	fix-mutex-crash.patch
	"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	go mod vendor -v
	default_prepare
}

build() {
	go build -mod=vendor \
		-ldflags "-linkmode=external -extldflags \"$LDFLAGS\" \
			-X main.version=$pkgver -X main.builtBy=Alpine_Linux \
			-X main.commit=2534983d96c431430e9263c27ce5bfa36b66c3d5" \
		-v .
}

check() {
	go test -v ./...
}

package() {
	install -Dm0755 "$pkgname" -t "$pkgdir"/usr/bin
	install -Dm0644 "$pkgname".desktop -t "$pkgdir"/usr/share/applications
	install -Dm0644 default-config.toml -t "$pkgdir"/usr/share/"$pkgname"
}

sha512sums="
575d2e9752387614c9fb70485c559d3dad5838ad8a0fb01874757e3bcb076e278966f6c46ba7ec59f9deb079de0c45b19a7b1bf75664e64b55b4f85ffa699f54  amfora-1.10.0.tar.gz
38f442ac88a2a793e5e29a2a470dad62eea047d090ae9df417798b03c471bec7b545c1022cf18172074cbf311c0b4092bcd50cd5b3599a7de09a821803a64f64  fix-mutex-crash.patch
"
